package com.kakame.codenews.front.user.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.kakame.codenews.base.web.annotation.CacheOperate;
import com.kakame.codenews.base.web.enumeration.CacheOperateType;
import com.kakame.codenews.base.web.fast.mapping.common.User;
import com.kakame.codenews.front.user.dao.FrontUserDao;
import com.kakame.codenews.front.user.service.FrontUserService;

@Service
public class FrontUserServiceImpl implements FrontUserService {
    @Resource
    private FrontUserDao userDao;

    @Override
    public User findByUserAccountOrEmail(String userName) {
        User user = userDao.findByUserAccountOrEmail(userName);
        return user;
    }

    @Override
    public int register(String userName, String userPwd) {
        int rows = userDao.register(userName, userPwd);
        return rows;
    }

	@Override
	@CacheOperate(operateType = CacheOperateType.GET, returnType = User.class)
	public User getById(String userId) {
		return userDao.getById(userId);
	}

    @Override
    public int update(User user) {
        return userDao.update(user);
    }

    @Override
    public User get(User user) {
        return userDao.get(user);
    }
}
